<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/common/taglibs.jsp"%>
<script type="text/javascript">
$(function(){
	$('#inputForm input').tooltip();
    $('#inputForm').ajaxForm({ 
        type: "post",
        dataType:"json",
        beforeSubmit: function(){
        	var checkReturn = $('#inputForm').checkForm(null,false);
        	if(checkReturn){
        		$("#sbmBtn").attr("disabled","disabled");
        	}
	       return checkReturn;
        },
        clearForm: false,
        resetForm: false,
        success: function(resp){
        	if(resp.status == '1' ){
        		ui.msg(resp.msg, 1);
        		ui.go(_ctx + '/pub/sysmgr/resmgr/res_list.do?refreshNode=' + '${selectedNodeId}');
        	}else{
        		ui.msg(resp.msg, 0);
        		$("#sbmBtn").removeClass("disabled").attr("disabled",null);
        	}
        },
        error:function(resp){
        	ui.msg('请求发送失败', 0);
    		$("#sbmBtn").removeClass("disabled").attr("disabled",null);
        }
    }); 
});
function changeOwnerType(){
	if($("#outurl").val()!='0'){
		$("#ownerTypeDiv").show();
	}else{
		$("#ownerTypeDiv").hide();
	}
}
function changeOwnerUrlPreFix(){
	if($("#ownerType").val()=='2'){
		$("#urlPreFixConfDiv").show();
	}else{
		$("#urlPreFixConfDiv").hide();
	}
}
</script>
<div class="widget-header widget-header-flat">
	<h5 class="smaller lighter">
		&nbsp;
	</h5>
	<div class="widget-toolbar no-border">
	</div>
</div>
<div class="widget-body">
	<div class="widget-main">
		<form class="form-horizontal" role="form" id="inputForm" action="${ctx}/pub/sysmgr/resmgr/add_res.do"  method="post" >
			<input type="hidden" name="ordNum" id="ordNum" value="${vo.ordernum}"/>	
			<input id="selectedNodeId" type="hidden" name="selectedNodeId" value="${selectedNodeId}"/>	
			<input id="operationType" type="hidden" name="operationType" value="${operationType}"/>	
			<input id="type" type="hidden" name="type" value="${type}"/>
			<div class="space-4"></div>
			<div class="form-group">
				<div class="col-sm-3 control-label no-padding-right" for="form-field-1">链接编码 *</div>
				<div class="col-sm-9">
					<input type="text" class="col-xs-10 col-sm-5" 
						value=""  name="id" id="id" datatype="require|limit|ajax" min="1" max="200"  placeholder="请输入资源编码"
						msg="请输入资源编码|请输入小于200位的资源编码|资源编码重复！" url="${ctx}/pub/sysmgr/resmgr/is_res_id_unique.do" 
						oldValue="${vo.id}" title="必填项,资源编码"/>
				</div>
			</div>
			<div class="space-4"></div>
			<div class="form-group">
				<div class="col-sm-3 control-label no-padding-right" for="form-field-1">链接名称 *</div>
				<div class="col-sm-9">
					<input type="text" class="col-xs-10 col-sm-5" 
						value=""  name="shortName" id="shortName"  datatype="require"  placeholder="请输入资源名称"
						msg="请输入资源名称" title="必填项,资源名称"/>
				</div>
			</div>
			<div class="space-4"></div>
			<div id="outUrlDiv" class="form-group">
				<div class="col-sm-3 control-label no-padding-right" for="form-field-1">是否外部链接</div>
				<div class="col-sm-9">
					<select name="outurl" id="outurl"  class="col-xs-10 col-sm-5"   onchange="changeOwnerType()">
						${cm:ctoption('YESNO','0') }
					</select>
				</div>
			</div>
			<div class="space-4"></div>
			<div class="form-group" style="display: none;" id="ownerTypeDiv">
				<div class="col-sm-3 control-label no-padding-right" for="form-field-1">所属系统类型</div>
				<div class="col-sm-9">
					<select name="ownerType" id="ownerType"    class="col-xs-10 col-sm-5" onchange="changeOwnerUrlPreFix()">
					    <option value="">-请选择-</option>
						${cm:ctoption('LinkOwnerType',null)}
					</select>
				</div>
			</div>
			<div class="space-4"></div>
			<div class="form-group" style="display: none;" id="urlPreFixConfDiv">
				<div class="col-sm-3 control-label no-padding-right" for="form-field-1">前缀配置文件参数。格式举例：uums_sys_prefix@app.properties</div>
				<div class="col-sm-9">
					<input type="text" class="col-xs-10 col-sm-5" 
						 name="ownerUrlPreFix" id="ownerUrlPreFix"  placeholder="请输入参数 "
						msg="请输入参数 "/>
				</div>
			</div>
			<div class="space-4"></div>
			<div id="urlDiv" class="form-group">
				<div id="urlTitle" class="col-sm-3 control-label no-padding-right" for="form-field-1">链接地址 *</div>
				<div class="col-sm-9">
					<input type="text" class="col-xs-10 col-sm-5" 
						value=""  name="url" id="url"  placeholder="请输入链接地址" datatype="require"
						msg="请输入链接地址" title="链接地址"/>
				</div>
			</div>
			<div class="space-4"></div>
			<div id="hiddenDiv" class="form-group">
				<div class="col-sm-3 control-label no-padding-right" for="form-field-1">仅开发模式 *</div>
				<div class="col-sm-9">
					<select name="fordev" id="fordev" datatype="require" msg="必选项"  class="col-xs-10 col-sm-5" >
						${cm:ctoption('YESNO','0') }
					</select>
				</div>
			</div>
			
			<div class="form-group">
				<div class="col-sm-3 control-label no-padding-right" for="form-field-1">选择链接分组 *</div>
				<div class="col-sm-9">
						<c:forEach var="g" items="${groups}">
						<c:set var="checked" value=""/>
						   <c:if test="${selectedNodeId eq g.id}">
						     <c:set var="checked" value="checked"/>
						   </c:if>
						   <div><input datatype="group" msg="必选项"  type="checkbox" name="linkGroups"  class="col-xs-5 col-sm-1"  ${checked} value="${g.id}" />${g.shortName}</div>
						</c:forEach>
				</div>
			</div>
			<div class="form-group">
			<div class="col-sm-3 control-label no-padding-right" for="form-field-1">按钮名称 </div>
			<div class="col-sm-9">
				<input type="text" class="col-xs-10 col-sm-5" 
					value=""  name="btnValue" id="btnValue"  placeholder="请输入按钮名称 "
					msg="请输入按钮名称 "/>
			</div>
			</div>
			<div class="space-4"></div>
			<div class="form-group">
				<div class="col-sm-3 control-label no-padding-right" for="form-field-1">备注 &nbsp</div>
				<div class="col-sm-9">
					<textarea type="text" class="col-xs-10 col-sm-5" name="remark" id="remark" placeholder="备注">${vo.remark}</textarea>
				</div>
			</div>
			<hr>
			  <div class="clearfix form-group">
				<div class="col-md-offset-3 col-md-9">
					<button type="submit" class="btn btn-sm btn-info" id="sbmBtn"><i class="icon-ok bigger-110"></i>提交</button>
		  		</div>
			</div>
		</form>
	</div>
</div>